package com.etalk.crm.serviceImpl;

import com.etalk.crm.dao.LessonsMapper;
import com.etalk.crm.pojo.StudentLesson;
import com.etalk.crm.service.LessonsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Jordan
 */
@Service
public class LessonsServiceImpl implements LessonsService {

    @Resource
    private LessonsMapper lessonsMapper;

    /**
     * 查询用户已预约的课程
     * @param personId 学员id
     * @param pageNum 页码
     * @param pageSize 每页记录数
     * @return 结果
     */
    @Override
    public PageInfo<StudentLesson> searchBookedList(Integer personId, int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<StudentLesson> list=lessonsMapper.selectStudentBookedLessonListByPersonId(personId);

        return new PageInfo<>(list);
    }

    /**
     * 查询用户已完成的课程
     * @param personId 学员id
     * @param pageNum 页码
     * @param pageSize 每页记录数
     * @return 结果
     */
    @Override
    public PageInfo<StudentLesson> searchCompletedList(Integer personId, int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<StudentLesson> list=lessonsMapper.selectStudentCompletedLessonListByPersonId(personId);
        return new PageInfo<>(list);
    }
}
